﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class but_control_Search : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.Page.IsPostBack)
        {
            bindCbo();
        }
    }
    private void bindCbo()
    {
        CommonDAO dao = new CommonDAO();
        cboParent.DataSource = dao.queryForTable("sanPham_NhomGetForSearchParent", "s");
        cboParent.DataBind();

        cboLoai.DataSource = dao.queryForTable("sanpham_loaiGetForSearch", "s");
        cboLoai.DataBind();

        cboGia.DataSource = dao.queryForTable("SanPham_KhoangGiaSearch_Getall", "s");
        cboGia.DataBind();
        cboParent_SelectedIndexChanged(null,null);
    }
    protected void cboParent_SelectedIndexChanged(object sender, EventArgs e)
    {
        if(cboParent.SelectedValue == "-1")
        {
            CommonDAO dao = new CommonDAO();
            cboGroup.DataSource = dao.sanPham_Nhom_getAllGroup();
            cboGroup.DataBind();
        }
        else{
            CommonDAO dao = new CommonDAO();
            cboGroup.DataSource = dao.sanPham_NhomGetForSearchNhom(cboParent.SelectedValue);
            cboGroup.DataBind();
        }
    }
}
